package com.guigu.www.mapper;

import com.guigu.www.pojo.Rubric;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author DengHao
 * @since 2021-10-21
 */
public interface RubricMapper extends BaseMapper<Rubric> {
    /*陈显科   根据评估类型查询对应的题目*/
    @Select("SELECT * FROM rubric WHERE rub_id IN(\n" +
            "SELECT rub_id FROM question_details WHERE ques_id IN(\n" +
            "SELECT ques_id FROM question WHERE ques_id IN(\n" +
            "SELECT ques_id FROM question WHERE ques_test_type=#{rid} AND ques_state=0)))")
    List<Rubric> selectRubricByQuesId(int rid);

    /*邓浩添加   根据问卷ID查询对应的题目*/
    @Select("SELECT * FROM rubric WHERE rub_id IN(\n" +
            "SELECT rub_id FROM question_details WHERE ques_id IN(\n" +
            "SELECT ques_id FROM question WHERE ques_id=#{quesId}))")
    List<Rubric> queryRubricByQuesId(@Param("quesId") int quesId);

    // 邓浩添加，查询当前类型可用的问卷的题目
    @Select("SELECT * FROM rubric WHERE rub_id IN (\n" +
            "SELECT rub_id FROM question_details WHERE ques_id = (\n" +
            "SELECT ques_id FROM question WHERE ques_test_type = #{rubType} AND ques_state = 0))")
    List<Rubric> queryRubric(@Param("rubType") Integer rubType);

    //罗露金
    @Select("SELECT rub.* FROM question qu ,`rubric` rub, `question_details` qd" +
            " WHERE qu.ques_id=qd.ques_id AND qd.rub_id=rub.rub_id " +
            "AND qu.ques_id = #{quesId}")
    List<Rubric> selectByquesId(Integer quesId);
}
